// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0

import { Button, GroupBox, TabWidget, VerticalBox } from "std-widgets.slint";

export component TestCase inherits Window {
    TabWidget {
        Tab {
            title: "First Tab";

            VerticalBox {
                alignment: start;

                GroupBox {
                    title: "Content of first tab";

                    Button {
                        text: "Button 1";
                    }
                }
            }
        }

        Tab {
            title: "Second Tab";

            VerticalBox {
                alignment: start;

                GroupBox {
                    title: "Content of second tab";

                    Button {
                        text: "Button 2";
                    }
                }
            }
        }

        Tab {
            title: "Third Tab";

            VerticalBox {
                alignment: start;

                GroupBox {
                    title: "Content of third tab";

                    Button {
                        text: "Button 3";
                    }
                }
            }
        }
    }
}

/*
```rust
let instance = TestCase::new().unwrap();

let mut tabbar_search = slint_testing::ElementHandle::find_by_element_id(&instance, "TabBarHorizontalImpl::root");
let tabbar = tabbar_search.next().unwrap();
assert_eq!(tabbar.accessible_item_count(), Some(3));

let mut tab1_search = slint_testing::ElementHandle::find_by_accessible_label(&instance, "First Tab");
let tab1 = tab1_search.next().unwrap();
// First tab panel is visible and has the same accessible label
assert!(tab1_search.next().is_some());
assert!(tab1_search.next().is_none());

let mut tab2_search = slint_testing::ElementHandle::find_by_accessible_label(&instance, "Second Tab");
let tab2 = tab2_search.next().unwrap();
// Second tab panel is not active at first, so it is hidden.
assert!(tab2_search.next().is_none());

let mut tab3_search = slint_testing::ElementHandle::find_by_accessible_label(&instance, "Third Tab");
let tab3 = tab3_search.next().unwrap();
// Third tab panel is not active at first, so it is hidden.
assert!(tab3_search.next().is_none());


assert_eq!(tab1.accessible_item_index(), Some(0));
assert_eq!(tab1.accessible_item_selectable(), Some(true));
assert_eq!(tab1.accessible_item_selected(), Some(true));

assert_eq!(tab2.accessible_item_index(), Some(1));
assert_eq!(tab2.accessible_item_selectable(), Some(true));
assert_eq!(tab2.accessible_item_selected(), Some(false));

assert_eq!(tab3.accessible_item_index(), Some(2));
assert_eq!(tab3.accessible_item_selectable(), Some(true));
assert_eq!(tab3.accessible_item_selected(), Some(false));

// The accessible default action of tabs change the active tab panel
tab2.invoke_accessible_default_action();
assert_eq!(tab2.accessible_item_selectable(), Some(true));
assert_eq!(tab2.accessible_item_selected(), Some(true));
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "Second Tab").count(), 2);

assert_eq!(tab1.accessible_item_selectable(), Some(true));
assert_eq!(tab1.accessible_item_selected(), Some(false));
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "First Tab").count(), 1);

tab3.invoke_accessible_default_action();
assert_eq!(tab3.accessible_item_selectable(), Some(true));
assert_eq!(tab3.accessible_item_selected(), Some(true));
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "Third Tab").count(), 2);

assert_eq!(tab2.accessible_item_selectable(), Some(true));
assert_eq!(tab2.accessible_item_selected(), Some(false));
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "Second Tab").count(), 1);
```
*/
